﻿using Edu.Abstracts;
using Edu.Contracts;
using Edu.Entitys;
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;

namespace Edu.Services
{



    public class UserAppService : ApplicationService, IUserAppService
    {

        private readonly IAppUserRepository _userRepository;

        public UserAppService(IAppUserRepository userRepository)
        {
            _userRepository = userRepository;
        }

        public async Task<EduUserDto> GetAsync(Guid id)
        {
            var user = await _userRepository.GetAsync(id);
            return ObjectMapper.Map<AppUser, EduUserDto>(user);
        }

        public async Task<EduUserDto> UpdateAsync(EduUserUpdateDto eduInput)
        {
            var user = await _userRepository.GetAsync(eduInput.Id);

            user.Area = eduInput.Area;
            await _userRepository.UpdateAsync(user, true);
            return ObjectMapper.Map<AppUser, EduUserDto>(user);
        }



    }
}
